package com.gasstation

import java.util.Date

class InventoryPremium {
	Date transactionOn
	double premiumOpenGallons
	double premiumOpenInvCost
	double premiumPurchasedGallons
	double premiumPurchasedCost
	double premiumSaleGallons
	double premiumCloseGallons
	double premiumActualGallons
	double premiumAvgCost
	double premiumCost
	double premiumVariance

	// Automatically updated by GORM
	Date dateCreated
	// Automatically updated by GORM
	Date lastUpdated
	static mapping = { sort transactionOn:"asc" }
	static constraints = { transactionOn unique: true }
	void calculatePremiumCloseGallons(){
		premiumCloseGallons = premiumOpenGallons+premiumPurchasedGallons-premiumSaleGallons
	}
	void calculatePremiumAvgCost(){
		premiumAvgCost = (premiumOpenInvCost+premiumPurchasedCost)/(premiumOpenGallons+premiumPurchasedGallons)
	}
	void calculatePremiumCost(){
		premiumCost = premiumSaleGallons*premiumAvgCost
	}
	void calculatePremiumVariance(){
		premiumVariance = premiumActualGallons - premiumCloseGallons
	}
}
